package com.ldn.common.basic.dispose.vo;

import lombok.Getter;
import lombok.Setter;

/**
 * 统一的数据返回格式 返回结果数据集
 *
 * @author 李大牛家的牛 (scafel@163.com)
 * @product serverless
 * @className ResultDataVo
 * @createDate 2025/1/13 - 13:24
 * @description 统一的数据返回格式 返回结果数据集
 **/
@Getter
@Setter
public class ResultDataVo<T> {

    // 结果状态码
    private int status;
    // 结果描述
    private String message;
    // 结果数据集
    private T data;
    // 返回时间戳
    private long timestamp;

    public ResultDataVo() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> ResultDataVo<T> success(T data) {
        ResultDataVo<T> resultData = new ResultDataVo<>();
        resultData.setStatus(200);
        resultData.setMessage("操作成功");
        resultData.setData(data);
        return resultData;
    }

    public static <T> ResultDataVo<T> fail(int code, String message) {
        ResultDataVo<T> resultData = new ResultDataVo<>();
        resultData.setStatus(code);
        resultData.setMessage(message);
        return resultData;
    }
    
}
